package thread.threaddemo;

/**
 * @Author: wenjingyuan
 * @Date: 2022/11/09/11:09
 * @Description:interrupt（）方法
 */
public class ThreadInterrupt2 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread=new Thread(()->{
            while(!Thread.currentThread().isInterrupted()){
         //   while(!Thread.interrupted()){
                System.out.println("正在转账..");
            }
            System.out.println("险些误了大事！");
        });
        thread.start();
        Thread.sleep(1000);
        thread.interrupt();
        System.out.println("有内鬼，终止交易！");
    }
}
